<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/6/9
  Time: 10:15
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>管理员新增</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css">
</head>
<body>
<form class="layui-form">
    <div class="layui-form-item">
        <label class="layui-form-label">账 号</label>
        <div class="layui-input-inline">
            <%--lay-verify="required" 表示表单验证，必填--%>
            <input type="text" name="account" lay-verify="required" placeholder="请输入账号" autocomplete="off" class="layui-input">
        </div>
    </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密 码</label>
            <div class="layui-input-inline">
                <%--lay-verify="required" 表示表单验证，必填--%>
                <input type="password" name="password" lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
            </div>
        </div>
            <div class="layui-form-item">
                <label class="layui-form-label">姓 名</label>
                <div class="layui-input-inline">
                    <input type="text" name="name"  placeholder="请输入姓名" autocomplete="off" class="layui-input">
                </div>
            </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">手机号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="phone"  placeholder="请输入手机号" autocomplete="off" class="layui-input">
                    </div>
                </div>
    <div class="layui-form-item">
        <label class="layui-form-label">邮 箱</label>
        <div class="layui-input-inline">
            <input type="text" name="email" placeholder="请输入邮箱" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">状  态</label>
        <div class="layui-input-block">
            <input type="radio" name="status" value="0" title="注销">
            <input type="radio" name="status" value="1" title="正常" checked>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">性 别</label>
    <div class="layui-input-block">
        <input type="radio" name="sex" value="1" title="男" checked="">
        <input type="radio" name="sex" value="2" title="女">
        <input type="radio" name="sex" value="0" title="未知">
     </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">角 色</label>
        <div class="layui-input-inline">
            <select name="roleid">
                <c:forEach items="${roles}" var="role">
                    <option value="${role.id}">${role.explain}</option>
                </c:forEach>
            </select>
        </div>
    </div>
    <input type="hidden" name="operator" value="1">
    <div class="layui-form-item">
        <input type="submit" style="margin-left: 100px" lay-filter="add" lay-submit class="layui-btn" name="提交">
    </div>
</form>
<script src="${pageContext.request.contextPath}/static/layui/layui.js"></script>
<script>
    layui.use(['layer','form','jquery'],function () {
        var layer=layui.layer
            , form=layui.form
            , $=layui.$;
        layer.msg("Hello word");
        form.on("submit(add)",function (data) {
            $.post("/role/add2",data.field,function (result) {
                 if (result.code==0){
                     layer.msg("新增成功")
                     parent.layui.table.reload("roleTable",{
                         page:{
                             curr:1
                         }
                     })
                     //关闭本窗口
                     //
                     var index=parent.layer.getFrameIndex(window.name);
                     parent.layer.close(index);
                 }
            },"json")
            return false;
        })
    });
</script>
</body>
</html>
